package com.tianji.controller;

import com.tianji.entity.vo.ChatHistoryVO;
import com.tianji.entity.vo.MessageVO;
import com.tianji.entity.vo.SessionVO;
import com.tianji.service.ChatSessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("session")
public class ChatSessionController {
    @Autowired
    private ChatSessionService chatSessionService;

    @PostMapping
    public SessionVO createSession(@RequestParam(value = "n",defaultValue = "3") Integer num){
        SessionVO vo = chatSessionService.getSession(num);
        return vo;
    }

    @GetMapping("/hot")
    public List<SessionVO.Example> getHot(@RequestParam(value = "n",defaultValue = "3") Integer num){
        return chatSessionService.getHot(num);
    }
    @GetMapping("/{sessionId}")
    public List<MessageVO> getChatMessage(@PathVariable String sessionId){
        return chatSessionService.getChatMessage(sessionId);
    }

    /**
     * 查询历史会话列表
     */
    @GetMapping("/history")
    public Map<String, List<ChatHistoryVO>> queryHistorySession() {
        return this.chatSessionService.queryHistorySession();
    }



}
